﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bullet : MonoBehaviour
{
    public GameObject expObj;//爆炸特效
    public Transform firePos;//开火点
    void Start()
    {
        firePos=transform.parent;
    }
    //碰撞检测
    private void OnCollisionEnter(Collision collision)
    {
        if (expObj != null)
            Instantiate(expObj,transform.position,Quaternion.identity);
        BackToStartPoint();
    }
    void BackToStartPoint()
    {
        //打开忽略物理学运算 
        GetComponent<SphereCollider>().enabled = false;
        GetComponent<Rigidbody>().isKinematic = true;
        GetComponent<MeshRenderer>().enabled=false;
        //回到出发点
        transform.position = firePos.position;
    }
}
